<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" xmlns:width="http://www.w3.org/1999/xhtml">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">

<div class="modal fade" data-backdrop="static" data-keyboard="false" id="modal-alteration">
    <div class="modal-dialog" style="width:1400px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">变更记录</h4>
            </div>
            <div class="modal-body">
                <form id="queryAlterationForm" class="form-horizontal">
                    <input type="hidden" id="rppId" name="id">
                    <!--type="hidden"-->
                    <div style="float: left; width: 100%; height:0px" class="form-group">
                        <div class="row">
                            <div class="col-xs-12" style="padding-bottom: 10px">
                                <div class="form-inline">
                                    <div class="form-group" style="margin-right: 2px;">
                                        <label style="width: 100px;text-align: right">项目编号：</label>
                                        <label style="margin-left:5px;margin-right: 20px"
                                               th:text="${rppProjectCode}"></label>
                                    </div>
                                    <div class="form-group" style="margin-right: 80px; margin-left:20px">
                                        <label>项目名称：</label>
                                        <label style="font-size: 14px;" th:text="${project.name}"></label>
                                    </div>
                                    <!--<input id="rppMatDesc" name="rppMatDesc">-->
                                    <div class="form-group" style="margin-right: 50px">
                                        <label>提报计划物料描述：</label>
                                        <label id="rppMatDesc" style="margin-left:5px;margin-right: 20px"></label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div hidden>
                        </div>
                    </div>
                </form>
                <div class="box-body">
                    <table id="bootstrap-table2"></table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" data-backdrop="static" data-keyboard="false" id="modal-warehouse">
    <div class="modal-dialog" style="width:1400px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">出库记录</h4>
            </div>
            <div class="modal-body">
                <form id="queryWarehouseForm" class="form-horizontal">
                    <input type="hidden" id="code" name="code">
                    <input type="hidden" id="tail" name="tail">
                    <input type="hidden" id="material" name="material">

                    <div style="float: left; width: 100%; height:0px" class="form-group">
                        <div class="row">
                            <div class="col-xs-12" style="padding-bottom: 10px">
                                <div class="form-inline">
                                    <div class="form-group" style="margin-right: 2px;">
                                        <label style="width: 100px;text-align: right">项目编号：</label>
                                        <label style="margin-left:5px;margin-right: 20px"
                                               th:text="${rppProjectCode}"></label>
                                    </div>
                                    <div class="form-group" style="margin-right: 80px; margin-left:20px">
                                        <label>项目名称：</label>
                                        <label style="font-size: 14px;" th:text="${project.name}"></label>
                                    </div>
                                    <div class="form-group" style="margin-right: 50px">
                                        <label>提报计划物料描述：</label>
                                        <label id="warehouse"></label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div hidden>
                        </div>
                    </div>
                </form>
                <div class="box-body">
                    <table id="bootstrap-table3"></table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" data-backdrop="static" data-keyboard="false" id="modal-appoint">
    <div class="modal-dialog" style="width:1400px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">库存记录</h4>
            </div>
            <div class="modal-body">
                <form id="queryDailyForm" class="form-horizontal">
                    <input type="hidden" id="rppIdk" name="id">
                    <input type="hidden" id="rppMatDesc1" name="rppMatDesc">
                    <input type="hidden" id="rppProjectCode1" name="rppProjectCode">
                    <!--type="hidden"-->
                    <div style="float: left; width: 100%; height:0px" class="form-group">
                        <div class="row">
                            <div class="col-xs-12" style="padding-bottom: 10px">
                                <div class="form-inline">
                                    <div class="form-group" style="margin-right: 2px;">
                                        <label style="width: 100px;text-align: right">项目编号：</label>
                                        <label style="margin-left:5px;margin-right: 20px"
                                               th:text="${rppProjectCode}"></label>
                                    </div>
                                    <div class="form-group" style="margin-right: 80px; margin-left:20px">
                                        <label>项目名称：</label>
                                        <label style="font-size: 14px;" th:text="${project.name}"></label>
                                    </div>
                                    <div class="form-group" style="margin-right: 50px">
                                        <label>提报计划物料描述：</label>
                                        <label id="appoint"></label>
                                    </div>
                                    <div class="form-group" style="margin-right: 50px">
                                        <label>提报数量：</label>
                                        <label id="rppNum"></label>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div hidden>
                        </div>
                    </div>
                </form>
                <div id="assignInfo" class="box-body" style="margin-top: 30px">
                    <div class="bootstrap-table">
                        <div class="fixed-table-container">
                            <div class="fixed-table-body">
                                <table id="assignTable" class="table table-hover table-striped">
                                    <thead class="bootstrap-table4-sticky-header">
                                    <tr>
                                        <th colspan="3" style="height: 24px;padding: 8px;">
                                            手动指定库存信息如下
                                        </th>
                                    </tr>
                                    <tr>
                                        <th style="height: 24px;padding: 8px;">
                                            物料描述
                                        </th>
                                        <th style="height: 24px;padding: 8px;">
                                            数量
                                        </th>
                                        <th style="height: 24px;padding: 8px;">
                                            单位
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td id="assignMatDesc">

                                        </td>
                                        <td id="assignNum">

                                        </td>
                                        <td id="assignUnit">

                                        </td>
                                    </tr>
                                    </tbody>

                                </table>
                            </div>
                        </div>
                        <!--                    <div class="row">-->
                        <!--                        <div class="form-group" style="width: 100%">-->
                        <!--                            <label class="control-label">手动指定信息如下</label>-->
                        <!--                        </div>-->
                        <!--                        <div class="form-inline">-->
                        <!--                            <div class="form-group">-->
                        <!--                                <label class="control-label">物料描述:</label>-->
                        <!--                                <label class="control-label form-control" id="assignMatDesc"></label>-->
                        <!--                            </div>-->
                        <!--                            <div class="form-group">-->
                        <!--                                <label class="control-label">数量:</label>-->
                        <!--                                <label class="control-label form-control" id="assignNum"></label>-->
                        <!--                            </div>-->
                        <!--                            <div class="form-group">-->
                        <!--                                <label class="control-label">单位:</label>-->
                        <!--                                <label class="control-label form-control" id="assignUnit"></label>-->
                        <!--                            </div>-->
                        <!--                        </div>-->
                        <!--                    </div>-->
                    </div>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table4"></table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" data-backdrop="static" data-keyboard="false" id="modal-merge">
    <div class="modal-dialog" style="width:1600px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">合报记录</h4>
            </div>
            <div class="modal-body">
                <form id="mergeForm" class="form-horizontal">
                    <input type="hidden" id="rppIdm" name="id">
                    <!--type="hidden"-->
                    <div style="float: left; width: 100%; height:0px" class="form-group">
                        <div class="row">
                            <div class="col-xs-12" style="padding-bottom: 10px">
                                <div class="form-inline">
                                    <div class="form-group" style="margin-right: 2px;">
                                        <label style="width: 100px;text-align: right">项目编号：</label>
                                        <label style="margin-left:5px;margin-right: 20px"
                                               th:text="${rppProjectCode}"></label>
                                    </div>
                                    <div class="form-group" style="margin-right: 80px; margin-left:20px">
                                        <label>项目名称：</label>
                                        <label style="font-size: 14px;" th:text="${project.name}"></label>
                                    </div>
                                    <div class="form-group" style="margin-right: 50px">
                                        <label>提报计划物料描述：</label>
                                        <label id="merge"></label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div hidden>
                        </div>
                    </div>
                </form>
                <div class="box-body">
                    <table id="bootstrap-table5"></table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<section class="content-header">
    <h1 style="font-size: 26px; height:15px">项目采购计划明细</h1>

</section>

<section class="content" style="margin-top: 5px">
    <div class="row">
        <!--<div style="float: left; width: 100%; height:60px" class="form-group">-->
        <!--<hr style="border-top: 1px solid #FFFFFF;">-->
        <!--<div class="row">-->

        <!--<div class="form-inline">-->
        <!--<div class="form-group" style="margin-right: 2px;">-->
        <!--<label style="width: 100px;text-align: right">项目编号：</label>-->
        <!--<label style="margin-left:5px;margin-right: 20px"-->
        <!--th:text="${rppProjectCode}"></label>-->
        <!--</div>-->
        <!--<div class="form-group" style="margin-right: 80px; margin-left:20px">-->
        <!--<label>项目名称：</label>-->
        <!--<label style="font-size: 16px;" th:text="${project.name}"></label>-->
        <!--</div>-->
        <!--<div class="form-group" style="margin-right: 50px">-->
        <!--<label>项目数量：</label>-->
        <!--<label th:text="${project.num}"></label>-->
        <!--</div>-->
        <!--<div class="form-group" style="margin-right: 60px;font-weight: 900;">-->
        <!--<label>&nbsp;&nbsp;&nbsp;设计任务状态：</label>-->
        <!--<span th:if="${project.designTaskStatus==0}">未开始</span>-->
        <!--<span th:if="${project.designTaskStatus==1}">执行中</span>-->
        <!--<span th:if="${project.designTaskStatus==2}">已完成</span>-->
        <!--</div>-->
        <!--<div class="form-group" style="margin-right: 60px;font-weight: 900;">-->
        <!--<label>&nbsp;&nbsp;&nbsp;&nbsp;生产状态：</label>-->
        <!--<span th:if="${projectStatus.proProductionStatus==1}">制作中</span>-->
        <!--<span th:if="${projectStatus.proProductionStatus==2}">待制作</span>-->
        <!--<span th:if="${projectStatus.proProductionStatus==3}">暂缓</span>-->
        <!--<span th:if="${projectStatus.proProductionStatus==4}">完成</span>-->
        <!--</div>-->
        <!--<div class="form-group" style="margin-right: 10px;">-->
        <!--<label>未回计划/采购计划：</label>-->
        <!--<label style="font-weight: 900;color: #FF0000;font-size: 16px;"-->
        <!--th:text="${plan.notBack}"></label>-->
        <!--<label>/</label>-->
        <!--<label th:text="${plan.plannedQuantity}"></label>-->
        <!--</div>-->
        <!--<div class="form-group">-->
        <!--<label>(不包括原材料)</label>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
        <!--<div hidden>-->
        <!--</div>-->
        <!--</div>-->
        <div class="col-xs-12">

            <div class="box">
                <div class="box-header">
                    <div class="row" style="float: left; width: 100%; line-height:40px">
                        <div class="form-inline">
                            <div class="form-group" style="margin-right: 2px;">
                                <label style="width: 100px;text-align: right">项目编号：</label>
                                <label style="margin-left:5px;margin-right: 20px"
                                       th:text="${rppProjectCode}"></label>
                            </div>
                            <div class="form-group" style="margin-right: 80px; margin-left:20px">
                                <label>项目名称：</label>
                                <label style="font-size: 16px;" th:text="${project.name}"></label>
                            </div>
                            <div class="form-group" style="margin-right: 50px">
                                <label>项目数量：</label>
                                <label th:text="${project.num}"></label>
                            </div>
                            <div class="form-group" style="margin-right: 60px;font-weight: 900;">
                                <label>&nbsp;&nbsp;&nbsp;设计任务状态：</label>
                                <span th:if="${project.designTaskStatus==0}">未开始</span>
                                <span th:if="${project.designTaskStatus==1}">执行中</span>
                                <span th:if="${project.designTaskStatus==2}">已完成</span>
                            </div>
                            <div class="form-group" style="margin-right: 60px;font-weight: 900;">
                                <label>&nbsp;&nbsp;&nbsp;&nbsp;生产状态：</label>
                                <span th:if="${projectStatus.proProductionStatus==1}">制作中</span>
                                <span th:if="${projectStatus.proProductionStatus==2}">待制作</span>
                                <span th:if="${projectStatus.proProductionStatus==3}">暂缓</span>
                                <span th:if="${projectStatus.proProductionStatus==4}">完成</span>
                                <span th:if="${projectStatus.proProductionStatus==5}">取消</span>
                            </div>
                            <!--                            <div class="form-group" style="margin-right: 10px;">-->
                            <!--                                <label>未回计划/采购计划：</label>-->
                            <!--                                <label style="font-weight: 900;color: #FF0000;font-size: 16px;"-->
                            <!--                                       th:text="${plan.notBack}"></label>-->
                            <!--                                <label>/</label>-->
                            <!--                                <label th:text="${plan.plannedQuantity}"></label>-->
                            <!--                            </div>-->
                            <!--<div class="form-group">-->
                            <!--<label>(不包括原材料)</label>-->
                            <!--</div>-->
                        </div>
                    </div>
                    <form id="queryForm">
                        <div class="row">
                            <div class="form-inline">
                                <input hidden name="rppProjectCode" id="rppProjectCode"
                                       th:value="${rppProjectCode}">
                                <!--<div class="form-group" style="margin-right: 10px;">-->
                                    <!--<label style="width: 85px;text-align: right">项目信息</label>-->
                                    <!--<input hidden name="rppProjectCode" id="rppProjectCode"-->
                                           <!--th:value="${rppProjectCode}">-->
                                    <!--<input type="text" style="width:250px;border-radius: 5px" maxlength="255"-->
                                           <!--name="projectName" class="form-control" placeholder="请输入项目名称">-->
                                <!--</div>-->
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>提报物料描述</label>
                                    <input type="text" style="width:180px;border-radius: 5px" maxlength="255"
                                           name="rppMatDesc" class="form-control" placeholder="请输入提报计划物料名称">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>提报数量</label>
                                    <input type="text" style="width:150px;border-radius: 5px" maxlength="255"
                                           name="rppNum" class="form-control" placeholder="请输入提报数量">
                                </div>
                                <div class="form-group" style="margin-right: 10px";>
                                    <label>提报人</label>
                                    <input type="text" style="width:150px;border-radius: 5px" maxlength="255"
                                           name="rppDesigner" class="form-control" placeholder="请输入提报人">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>计划员</label>
                                    <input type="text" style="width:150px;border-radius: 5px" maxlength="255"
                                           name="rppPlanner" class="form-control" placeholder="请输入计划员">
                                    <input hidden name="rppTypeId">
                                </div>
                                <div class="form-group" style="margin-right: 20px;">
                                    <label>提报时间</label>
                                    <input type="text" style="width:150px;border-radius: 5px" maxlength="255"
                                           class="form-control datepicker" name="startTime" readonly="readonly"/>
                                    <span>至</span>
                                    <input type="text" style="width:150px;border-radius: 5px" maxlength="255"
                                           class="form-control datepicker" name="endTime" readonly="readonly"/>
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>采购物料信息</label>
                                    <input type="text" style="width:250px;border-radius: 5px" maxlength="255"
                                           name="sppMat" class="form-control" placeholder="请输入SAP物料编号或采购物料名称">
                                </div>
                                <div class="form-group" style="margin-right: 5px;">
                                    <label style="width: 84px;text-align: right">计划提报类型</label>
                                    <select name="prot" class="form-control"
                                            style="width: 180px ;border-radius: 5px">
                                        <option value='' selected="selected">全部</option>
                                        <option value='1'>暂缓</option>
                                        <option value='2'>使用库存</option>
                                        <option value='5'>正常采购</option>
                                        <option value='6'>无状态</option>
                                        <option value='7'>甲供</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 5px;">
                                    <label style="width: 84px;text-align: right">是否合报</label>
                                    <select name="sppIntegraFlag" class="form-control"
                                            style="width: 180px ;border-radius: 5px">
                                        <option value='' selected="selected">全部</option>
                                        <option value='1'>合报</option>
                                        <option value='0'>未合报</option>
                                    </select>
                                </div>
                                <!--<div class="form-group" style="margin-right: 5px;">-->
                                <!--<label style="width: 84px;text-align: right">采购执行状态</label>-->
                                <!--<select name="proExe" class="form-control"-->
                                <!--style="width: 150px ;border-radius: 5px">-->
                                <!--<option value='' selected="selected">全部</option>-->
                                <!--<option value=7>计划编辑中</option>-->
                                <!--<option value=4>已导入OA</option>-->
                                <!--<option value=5>OA审核通过</option>-->
                                <!--<option value=6>OA审核不通过</option>-->
                                <!--</select>-->
                                <!--</div>-->
                                <!--                                <div class="form-group" style="margin-right: 5px;">-->
                                <!--                                    <label style="width: 84px;text-align: right">勾回货状态</label>-->
                                <!--                                    <select name="sppPreStatus" class="form-control"-->
                                <!--                                            style="width: 150px ;border-radius: 5px">-->
                                <!--                                        <option value=3 selected="selected">全部</option>-->
                                <!--                                        <option value=1>已回货</option>-->
                                <!--                                        <option value=2>未回货</option>-->
                                <!--                                    </select>-->
                                <!--                                </div>-->
                                <div class="form-group" style="margin-right: 85px;">
                                    <label>SAP回货状态</label>
                                    <select name="sppRetStatus" class="form-control"
                                            style="width: 150px ;border-radius: 5px">
                                        <option value=3 selected="selected">全部</option>
                                        <option value=1>已回货</option>
                                        <option value=2>未回货</option>
                                    </select>
                                </div>
                                <button style=" border-radius: 5px"
                                        type="button" class="btn btn-success" id="btn-search">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>

                        <div class="row" style="margin-top: 10px;padding-bottom: 5px">
                            <!--<div class="form-inline">-->

                            <!--</div>-->
                            <hr style="border-top: 2px solid #D2D6DE; width: 100%; height:0px">
                            <div style="float: left; width: 100%; height:10px">
                                <div class="nav-tabs-custom" autocomplete="off">
                                    <ul class="nav nav-tabs" id="navTab">
                                        <li id="btn_material" class="active"><a onclick="searchTable(-1)" data-id="-1"
                                                                                href="#material" data-toggle="tab"
                                                                                aria-expanded="true">全部(<label
                                                th:text="${material.materialNum}"></label>)</a></li>
                                        <li th:each="type, stat : ${types}"><a name="tabMenu"
                                                                               th:onclick="|searchTable(${type.id})|"
                                                                               href="javascript:void(0)"
                                                                               th:attr="data-expanded=${stat.first ? true : false},data-id=${type.id}"
                                                                               data-toggle="tab">[[${type.name}]](<label
                                                th:text="${type.num}"></label>)</a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table1" data-height="800"></table>
                </div>
            </div>
        </div>
    </div>
</section>

<div th:include="include :: footer"></div>
<script th:inline="javascript">

    var table;
    var colors = ['', "label-warning", "label-warning", "label-warning", "label-info", "label-success", "label-danger"];
    var colors1 = ['', "label-danger", "label-warning", "label-info", "label-primary", "label-success", "label-default"];

    /**
     * 查看变更记录
     */
    function openAlteration(rppId, rppMatDesc) {
        $('#rppId').val(rppId);
        $('#rppMatDesc').text(rppMatDesc);
        table1 = js.table.init({
            showColumns: false,
            id: "bootstrap-table2",
            queryForm: "queryAlterationForm",
            url: ctx + "buy/planTraManage/alteration",
            showExport: false,
            columns: [
                {
                    title: '序号', field: 'id', width: '40',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: '变更前物料描述', field: 'rpcMatDesc', width: '200'},
                {title: '变更后物料描述', field: 'rpcNewMatDesc', width: '200'},
                {title: '更改前数量', field: 'rpcNum', width: '60'},
                {title: '更改后数量', field: 'rpcNewNum', width: '60'},
                {title: '单位', field: 'rpcUnit', width: '60'},
                // {
                //     title: '变更原因', field: 'spcChangeFlag', width: '80',
                //     formatter: function (value, row, index, field) {
                //         if (value == 1) {
                //             return '数量变更';
                //         } else if (value == 2) {
                //             return '名称变更';
                //         }
                //     }
                // },
                {title: '变更日期', field: 'rpcChangeTime', width: '100'},
            ]
        });

        js.modal.open("modal-alteration");
        js.table.refresh(table1);
    }

    /**
     * 查看出库记录
     */
    function openWarehouse(rppId) {
        var data = $('#bootstrap-table1').bootstrapTable('getRowByUniqueId', rppId);//行的数据
        $('#code').val(data.sppProjectCode);
        $('#tail').val(data.sppTrackCode);
        $('#material').val(data.sppMatDesc);
        $('#warehouse').text(data.rppMatDesc);


        table1 = js.table.init({
            showColumns: false,
            id: "bootstrap-table3",
            queryForm: "queryWarehouseForm",
            url: ctx + "buy/planTraManage/warehouse",
            showExport: false,
            columns: [
                {
                    title: '序号', field: 'cid', width: '40',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: '出库项目编码', field: 'code', width: '80'},
                {title: '出库项目名称', field: 'name', width: '240'},
                {title: '需求跟踪号', field: 'tail', width: '80'},
                {title: '物料编码', field: 'sapCode', width: '80'},
                {title: '物料描述', field: 'material', width: '180'},
                {title: '出库数量', field: 'num', width: '80'},
                {title: '出库重量', field: 'weight', width: '80'},
                {title: '领取人', field: 'person', width: '80'},
                {title: '领料车间', field: 'workshop', width: '80'},
                {title: '出库日期', field: 'date', width: '80'},
                {
                    title: '出库类型', field: 'type', width: '80',
                    formatter: function (value, row, index, field) {
                        if (value == 0) {
                            return '领料出库';
                        } else if (value == 1) {
                            return '串料出库';
                        }
                    }
                },
                {title: '特殊说明', field: 'explain', width: '80'},

            ]
        });
        js.modal.open("modal-warehouse");
        js.table.refresh(table1);
    }


    /**
     * 外购件明细
     */
    function openAppointP(rppId) {
        var rowData = $("#bootstrap-table1").bootstrapTable('getRowByUniqueId', rppId);
        $("#assignMatDesc").text("");
        $("#assignNum").text("");
        $("#assignUnit").text("");
        if (rowData.rppAssignDesc != null && rowData.rppAssignDesc != '') {
            $("#assignMatDesc").text(rowData.rppAssignDesc === null ? '' : rowData.rppAssignDesc);
            $("#assignNum").text(rowData.rppDiyAssignUseStockNum === null ? '' : rowData.rppDiyAssignUseStockNum);
            $("#assignUnit").text(rowData.rppDiyAssignUseStockUnit === null ? '' : rowData.rppDiyAssignUseStockUnit);
            $("#assignInfo").show();
        } else {
            $("#assignInfo").hide();
        }
        $('#rppIdk').val(rppId);
        $('#appoint').text(rowData.rppMatDesc);
        $('#rppProjectCode1').val(rowData.rppProjectCode);
        $('#rppMatDesc1').val(rowData.sppMatDesc);
        $('#rppNum').text(rowData.rppNum);
        $('#rppDesigner').text(rowData.rppDesigner);
        table3 = js.table.init({
            showColumns: false,
            id: "bootstrap-table4",
            toolbar: 'toolBar4',
            queryForm: "queryDailyForm",
            url: ctx + "buy/planTraManage/appointP",
            pagination: false,
            showExport: false,
            onLoadSuccess: function (data) {
                if (data.rows.length > 0) {
                    $("#bootstrap-table4").show();
                } else {
                    $("#bootstrap-table4").hide();
                }
            },
            columns:
                [
                    [
                        {
                            "title": "库存内容如下",
                            "halign": "center",
                            "align": "center",
                            "colspan": 5
                        }
                    ],
                    [
                        {
                            title: '序号', field: 'id', width: '40',
                            formatter: function (value, row, index, field) {
                                return index + 1;
                            }
                        },
                        {title: '物料描述', field: 'matName', width: '180'},
                        {title: '库存数量', field: 'ityAvaNum', width: '60'},
                        {title: '库位', field: 'whiName', width: '80'},
                        {
                            title: '库房类型', field: 'site', width: '80',
                            formatter: function (value, row, index, field) {
                                return value;
                            }
                        },
                    ]
                ]
        });
        js.modal.open("modal-appoint");
        js.table.refresh(table3);

    }

    /**
     * 查看指定明细
     */
    function openAppoint(rppId) {
        var rowData = $("#bootstrap-table1").bootstrapTable('getRowByUniqueId', rppId);
        $("#assignMatDesc").text("");
        $("#assignNum").text("");
        $("#assignUnit").text("");
        if (rowData.rppAssignDesc != null && rowData.rppAssignDesc != '') {
            $("#assignMatDesc").text(rowData.rppAssignDesc === null ? '' : rowData.rppAssignDesc);
            $("#assignNum").text(rowData.rppDiyAssignUseStockNum === null ? '' : rowData.rppDiyAssignUseStockNum);
            $("#assignUnit").text(rowData.rppDiyAssignUseStockUnit === null ? '' : rowData.rppDiyAssignUseStockUnit);
            $("#assignInfo").show();
        } else {
            $("#assignInfo").hide();
        }
        $('#rppIdk').val(rppId);
        $('#appoint').text(rowData.rppMatDesc);
        $('#rppNum').text(rowData.rppNum);
        $('#rppDesigner').text(rowData.rppDesigner);
        table3 = js.table.init({
            showColumns: false,
            id: "bootstrap-table4",
            toolbar: 'toolBar4',
            queryForm: "queryDailyForm",
            url: ctx + "buy/planTraManage/appoint",
            pagination: false,
            showExport: false,
            onLoadSuccess: function (data) {
                if (data.rows.length > 0) {
                    $("#bootstrap-table4").show();
                } else {
                    $("#bootstrap-table4").hide();
                }
            },
            columns:
                [
                    [
                        {
                            "title": "指定库存内容如下",
                            "halign": "center",
                            "align": "center",
                            "colspan": 10
                        }
                    ],
                    [
                        {
                            title: '序号', field: 'id', width: '40',
                            formatter: function (value, row, index, field) {
                                return index + 1;
                            }
                        },
                        {title: '指定计划跟踪号', field: 'cg', width: '80'},
                        {title: '指定物料描述', field: 'matName', width: '180'},
                        {title: '标记数量', field: 'num', width: '60'},
                        {title: '库存数量', field: 'ityAvaNum', width: '60'},
                        {title: '指定项目编号', field: 'code', width: '60'},
                        {title: '指定项目名称', field: 'name', width: '240'},
                        {title: '调整类型', field: 'comment', width: '80'},
                        {title: '库位', field: 'whiName', width: '80'},
                        {
                            title: '库房类型', field: 'site', width: '80',
                            formatter: function (value, row, index, field) {
                                return value;
                            }
                        },
                    ]
                ]
        });
        js.modal.open("modal-appoint");
        js.table.refresh(table3);

    }

    /**
     * 查看合报记录
     */
    function openMerge(rppId, rppMatDesc) {

        $('#rppIdm').val(rppId);
        $('#merge').text(rppMatDesc);

        table4 = js.table.init({
            showColumns: false,
            id: "bootstrap-table5",
            queryForm: "mergeForm",
            url: ctx + "buy/planTraManage/merPurchasingOpen",
            showExport: false,
            columns: [
                {
                    title: '序号', field: 'id', width: '40',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: '提报物料描述', field: 'rppMatDesc', width: '180'},
                {title: '提报数量', field: 'rppNum', width: '40'},
                {title: '提报单位', field: 'rppUnit', width: '40'},
                {title: '标准号', field: 'rppStandardNo', width: '100'},
                {title: '提报项目编号', field: 'rppProjectCode', width: '60'},
                {title: '提报项目名称', field: 'rppProjectName', width: '180'},
                {title: '计划号', field: 'rppPlanNo', width: '80'},
                {title: '提报时间', field: 'rppCreateTime', width: '80'},
                {title: '合报后项目编号', field: 'sppProjectCode', width: '60'},
                {title: '合报后项目名称', field: 'sppProjectName', width: '180'},

            ]
        });
        js.modal.open("modal-merge");
        js.table.refresh(table4);

    }

    /**
     * sheet页按类别查询显示
     */
    function searchTable(type) {
        $("#queryForm input[name='rppTypeId']").val(type);
        js.table.search(table);
    }


    $(function () {
        /**
         * 加载列表
         */
        table = js.table.init({
            id: "bootstrap-table1",
            url: ctx + "buy/planTraManage/detail",
            firstLoad: false,
            showColumns: true,
            showExport: false,
            pagination: true,                                   // 是否显示分页
            pageNumber: 1,                                      // 默认第一页
            pageSize: 50,                                       // 每页的记录行数
            pageList: [50, 100, 150, 200, 300],               // 可供选择的每页的行数
            uniqueId: "rppId",
            onLoadSuccess: function (data) {
                // if(data.rows.length>0){
                //     $("#navTab").find("li").removeAttr("class");
                //     $("[name='tabMenu']").each(function () {
                //        if($(this).attr("data-id")==data.rows[0].rppTypeId){
                //            $(this).parent().attr("class","active");
                //            return false;
                //        }
                //     });
                // }
            },
            columns: [
                {
                    title: '序号', field: 'id', width: '30',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: '提报日期', field: 'rppCreateTime', width: '80'},
                {title: '提报物料描述', field: 'rppMatDesc', width: '160'},
                {
                    title: '提报数量', field: 'rppNum', width: '50',
                    formatter: function (value, row, index) {
                        if (row.rppNum == null) {
                            row.rppNum = '';
                        }
                        return row.rppNum + row.rppUnit;
                    }
                },
                {title: '提报人', field: 'rppDesigner', width: '60'},
                {title: '跟踪号', field: 'sppTrackCode', width: '80'},
                {title: '物料编码', field: 'sppSapCode', width: '60'},
                {
                    title: '采购物料描述', field: 'sppMatDesc', width: '180',
                    formatter: function (value, row, index) {
                        if (row.rppUseStock === 1 || row.rppIsFlag === "1") {
                            return "--";
                        }
                        return value;
                    }
                },
                {
                    title: '采购数量', field: 'sppNum', width: '50',
                    formatter: function (value, row, index) {
                        if (row.rppUseStock === 1 || row.rppIsFlag === "1") {
                            return "--";
                        } else {
                            if (row.sppNum == null) {
                                return '';
                            }
                            return row.sppNum + row.sppUnit;
                        }
                    }
                },
                {title: '备注计划用途', field: 'sppProjectName', width: '180'},
                {
                    title: '计划提报类型', field: 'prot', width: '60',
                    formatter: function (value, row, index) {
                        if (value === 1) {
                            return '<span class="badge ' + colors1[value] + '">' + '暂缓' + '</span>';
                        } else if (value === 2) {
                            return '<span class="badge ' + colors1[value] + '">' + '使用库存' + '</span>';
                        }
                        else if (value === 5) {
                            return '<span class="badge ' + colors1[value] + '">' + '正常采购' + '</span>';
                        } else if (value === 6) {
                            return '<span class="badge ' + colors1[value] + '">' + '无状态' + '</span>';
                        } else if (value === 7) {
                            return '<span class="badge" style="color: #FFFFFF;background: #00e765">' + '甲供' + '</span>';
                        }
                    }
                },
                // {
                //     title: '采购执行状态', field: 'proExe', width: '100',
                //     formatter: function (value, row, index) {
                //         if (value === 0) {
                //             return '';
                //         } else if (value === 1) {
                //             return '<span class="badge ' + colors[value] + '">' + '计划编辑中' + '</span> ';
                //         } else if (value === 2) {
                //             return '<span class="badge ' + colors[value] + '">' + '计划编辑中' + '</span> ';
                //         } else if (value === 3) {
                //             return '<span class="badge ' + colors[value] + '">' + '计划编辑中' + '</span> ';
                //         } else if (value === 4) {
                //             return '<span class="badge ' + colors[value] + '">' + '已导入OA' + '</span> ' + "<br>" + row.spiCreateTime;
                //         } else if (value === 5) {
                //             return '<span class="badge ' + colors[value] + '">' + 'OA审核通过' + '</span> ';
                //         } else if (value === 6) {
                //             return '<span class="badge ' + colors[value] + '">' + 'OA审核不通过' + '</span> ';
                //         }
                //     }
                // },
                {
                    title: '回货状态', field: 'isReturn', width: '100',
                    formatter: function (value, row) {
                        if (row.prot == 5) {
                            if (row.isReturn === 1) {
                                return '<span class="badge label-success">已回货</span> ';
                            } else {
                                return '<span class="badge label-default">未回货</span> ';
                            }


                        } else {
                            return "";
                        }
                    }
                },
                // {title: '回货数量', field: 'sppNum', width: '120'},
                {
                    title: '是否合报', field: 'sppIntegraFlag', width: '100',
                    formatter: function (value, row) {
                        if (row.sppIntegraFlag === 1) {
                            return '<span class="badge label-warning">合报</span> ';
                        } else {
                            return '<span class="badge label-default">未合报</span> ';
                        }

                    }
                },
                // /**采购过程状态*/
                // {title: '回货进度', field: 'sppProgress', width: '120'}, /**追计划信息*/
                //
                // {
                //     title: '回货类型<br>回货时间', field: 'stockStatus', width: '100',
                //     formatter: function (value, row, index) {
                //         if (row.stockTime == null) {
                //             row.stockTime = '';
                //         }
                //         return row.stockStatus + "<br>" + row.stockTime;
                //
                //     }
                //
                // },

                {
                    title: '库存', field: 'stockNum', width: '60',
                    formatter: function (value, row) {
                        if (row.rppIsFlag === "1") {
                        } else {
                            if (row.rppTypes === "外购件") {
                                if (row.stockNumW>0){

                                    return row.stockNumW + row.rppUnit;
                                } else {
                                    return '-'
                                }
                            }
                        }
                        if (row.prot === 5) {
                            if (value > 0) {

                                return row.stockNum + row.rppUnit;
                            } else {
                                return 0;
                            }
                        } else {
                            return '-'
                        }
                    }
                }, /**有库存、无库存*/
                {
                    title: '库位', field: 'whiName', width: '60',
                    formatter: function (value, row) {
                        if (row.rppIsFlag === "1") {
                        } else {
                            if (row.rppTypes === "外购件"){

                                if (row.stockNumW==0) {
                                    return '-';
                                }else if(row.stockNumW>0){

                                    if (row.whiNameNum==1) {
                                        return row.whiNameSum;
                                    }else {
                                        return '多库位';
                                    }
                                }
                            }
                        }
                        return value;
                    }
                }, /**有库存、无库存*/
                {title: '计划员', field: 'rppPlanner', width: '60'},

                {
                    title: '操作', width: '100',
                    formatter: function (value, row, index) {
                        var actions = [];
                        // if (row.rpcRppId != null) {
                        //     actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="openAlteration(\'' + row.rppId + '\',\'' + row.rppMatDesc + '\')"> 变更记录</a> ');
                        // }
                        // if (row.isReturn === 1) {
                        //     actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="openWarehouse(' + row.rppId + ')"> 出库记录</a> ');
                        // }
                        if (row.rppIsFlag === "1") {
                            actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="openAppoint(' + row.rppId + ')"> 指定记录</a> ');
                        } else {

                            if (row.rppTypes === "外购件"&&row.stockNumW>0) {
                                actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="openAppointP(' + row.rppId + ')"> 库存记录</a> ');
                            }
                        }
                        // if (row.sppIntegraFlag == 1) {
                        //     actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="openMerge(\'' + row.rppId + '\',\'' + row.rppMatDesc + '\')"> 合报记录</a> ');
                        // }
                        return actions.join('');
                    }
                }
            ]
        });

        searchTable(+$("li.active a").attr("data-id"));
        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });


        /** 表格搜索 */
        $("#btn-searchDaily").click(function () {
            js.table.search(table1);
        });

    });
</script>
</body>
</html>